Don't use file-truepath in Eglot (bug#70036)
authorTheodor Thornhill <theo@thornhill.no>
Sat, 30 Mar 2024 19:52:41 +0000 (20:52 +0100)
committerTheodor Thornhill <theo@thornhill.no>
Wed, 3 Apr 2024 13:02:16 +0000 (15:02 +0200)
commit08c80c45ddea17df87fc768a39dff353ccc13d3b
treea649606fee9322085ed24441a2c5a560a9889248
parent48dc75f2353152158fa325f5fbf154cdc75e8cfa
Don't use file-truepath in Eglot (bug#70036)

`file-truepath' is slow because of recursive calls and being implemented
in lisp.  It seems to not be needed in eglot, but it is used behind the
scenes in `find-buffer-visiting', thus appearing in profiles.  Moving
the implementation to a hash map will yield similar performance
benefits, but wouldn't require us to rewrite `file-truename' in C.

* lisp/progmodes/eglot.el (eglot-lsp-server): Convert 'managed-buffers'
to a hashmap.
(eglot-uri-to-path): Don't use file-truepath, as it is too slow to be
included in the hot path.
(eglot--on-shutdown): Use buffers from buffer map.
(eglot--managed-mode): Add buffer to map, rather than list. Also remove
it from the map on deactivation.
(eglot-handle-notification): Expose server and get buffer from the
buffer map.
lisp/progmodes/eglot.el